#ifndef MAKER_BINOCULAR_H
#define MAKER_BINOCULAR_H
#include <opencv2/opencv.hpp>
#include <libusb-1.0/libusb.h>


typedef unsigned char u8;

class makerbinocular {
public:
    makerbinocular();
    
    ~makerbinocular();
    
    void init();
    
    void get_frame(cv::Mat & left_image,  cv::Mat & right_image);
    
    bool is_initialized() {return initialized;}
    
    bool new_frame_arrived() {return has_new_frame;}
    
    void gamma_correction(cv::Mat & image);
    
    bool is_rgb_camera() {return is_rgb;}
    
private:
    
    libusb_device ** devs;
    libusb_context *contex = NULL;
    
    struct libusb_device_descriptor desc;
    struct libusb_config_descriptor * config;
    
    libusb_device *device;
    libusb_device_handle *dev_handle;

    u8 * datain;
    
    u8 bulk_ep_in;
    int buffer_size;
    
     /// time elapsed since last camera frame,  unit is us
    long time_elapsed;
    /// time elapsed since last imu frame,  unit is us
    long imu_time_elpased;
    /// the time elapsed since start of camera,  unit is us
    long current_image_time;
    ///  the time elapsed since the start of imu,  unit is us
    long current_imu_time;
    
    bool initialized;
    bool has_new_frame;
    bool is_rgb;    
    float gyro_raw[3];
    float acc_raw[3];
    
    float gamma_value;
  };

#endif
